<script language="javascript">
function calendar_onchange(){
	//alert('f.submit();');
	document.f.submit();
}

// for ajax show
function show_note(id, url) {
	if (Element.empty(id)) {
          new Ajax.Updater(id, url, {
            method:     'get',
            onFailure:  function() {Element.classNames(id).add('failure')},
            onComplete: function() {new Effect.BlindDown(id, {duration: 0.25})}
          });
    } else {
          new Effect[Element.visible(id) ? 
            'BlindUp' : 'BlindDown'](id, {duration: 0.25});
    }
}
</script>
<% form_tag( {:action => 'index', :move => 0}, :id=>'f', :name=>"f") do %>
﻿<div class=head>待办事项 - <%= @user.full_name %> - 
	<input name="seldate" type="text" id="date" onclick="new Calendar().show(this);" size="9" maxlength="10" 
	value="<%= session[:date].strftime("%Y-%m-%d")%>" readonly="readonly" />
	<input type='submit' style='display:none' />
</div>
<% end %>
<!--onpropertychange="f.submit();"-->
<div class=menu>
<%= link_to '创建任务', :controller => 'mytodo', :action => 'new', :back=> 'dashboard' %> |
<%= link_to '前一天', :controller => 'dashboard', :action => 'index', :move => -1 %> |
<%= link_to '今天', :controller => 'dashboard', :action => 'index', :today => 1 %> |
<%= link_to '下一天', :controller => 'dashboard', :action => 'index' , :move => 1 %> 
<hr size=1 />
</div>

<div class=area>
<% 	
	new_type = 0 	
	for todo in @todos  
%>
		<div class="entry">
			<%				
				if todo.e_type > new_type then
					case todo.e_type
						when 1
							area = "重要、紧急事项："
						when 2
							area = "重要、不紧急事项："
						when 3
							area = "不重要、紧急事项："
						else
							area = "不重要、不紧急事项："
					end
			%>
					<div class=todo_head><%= area %></div>
			<%
					new_type = todo.e_type
				end
				
				if todo.check_state == 1
			%>
					<div class='todo_done'>
			<%	
				else
			%>						
					<div class='todo'>
					<%= link_to '[X]', { :action => 'done', :id => todo }, :confirm => '确定已完成此任务?', :method => :post %>				
					<%= link_to '[E]',  :controller => 'mytodo', :action => 'edit', :id => todo, :back=> 'dashboard'  %>				
					<%= link_to '[C]',  :controller => 'mytodo', :action => 'continue', :id => todo, :back=> 'dashboard'  %>				
					<%= link_to '[T]',  :controller => 'mytodo', :action => 'timer', :id => todo, :back=> 'dashboard'  %>
					<%= link_to '[N]',  :controller => 'mytodo', :action => 'note', :id => todo, :back=> 'dashboard'  %>
			<% 
				end 
					if todo.is_full_day != 1
			%>
					<span class="time">
						<%= todo.start_time.strftime("%H:%M") %> - <%= todo.end_time.strftime("%H:%M") %>
					</span> &nbsp;&nbsp;
					<% end %>
					<%= h(todo.todo) %> | <%= todo.description %>
				</div>				
		</div>
<% end %>
</div>
<% if @todos.size== 0 or  @expires.size > 0  %>
<div class="dashboard" id="dashboard_alert">
	<div class="dashboard_head" id="dashboard_alert_head">提示信息</div>
	<div class="dashboard_body" id="dashboard_alert_body">
		<% if @todos.size== 0 %>
			<div id="dashboard_alert_today">今日还未创建任务。</div>			
		<% end %>
		<% if @expires.size > 0 %>
			<div id="dashboard_alert_expire">你有<%=@expires.size%>个未确认的任务。</div>
			<div id="dashboard_alert_expire_list">
				<% for todo in @expires %>
					<div class='todo'>
						<%= link_to '[X]', { :action => 'done', :id => todo }, :confirm => '确定已完成此任务?', :method => :post %>				
						<%= link_to '[E]',  :controller => 'mytodo', :action => 'edit', :id => todo, :back=> 'dashboard'  %>				
						<%= link_to '[C]',  :controller => 'mytodo', :action => 'continue', :id => todo, :back=> 'dashboard'  %>
						<%= link_to '[T]',  :controller => 'mytodo', :action => 'timer', :id => todo, :back=> 'dashboard'  %>
						<%= link_to '[N]',  :controller => 'mytodo', :action => 'note', :id => todo, :back=> 'dashboard'  %>
						<%= todo.create_for_date.to_s %> | 
						<%= link_to_remote( "#{todo.todo}",
								:update => "about-content-#{todo.id}",
								:url =>{ :action => :show_todo_notes, :id=> todo.id},
								:layout=>false,
								:complete => "new Effect[Element.visible('about-content-#{todo.id}') ? 'BlindUp' : 'BlindDown']('about-content-#{todo.id}', {duration: 0.25});" )
 						%>
						<div class="about-content" id="about-content-<%=todo.id%>" style="display: none"></div>
					</div>
				<% end %>
			</div>
		<% end %>
	</div>
</div>
<% end %>